Skip to content

[431] Update default page template for using hero section and shared widgets#22

Merged
VitalyyP merged 8 commits into
mainfrom
431-feature/update-default-page-template
Apr 23, 2025
Merged

[431] Update default page template for using hero section and shared widgets#22
VitalyyP merged 8 commits into
mainfrom
431-feature/update-default-page-template

Conversation

@VitalyyP
Copy link
Copy Markdown
Contributor

@VitalyyP VitalyyP commented Apr 22, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new "Default Hero" widget, allowing content editors to add a hero section with a title, optional subtitle, and a background image to pages.
    • Updated page structure to include a dedicated "header" area for hero content, separate from the main content area.
  • Style

    • Improved template and configuration formatting for better readability.
  • Refactor

    • Reorganized page field groups and area configurations to support the new hero widget and enhance content flexibility.

- Create default-hero widget module
- Add widget template
- Register widget in app.js
- Add header area with default-hero widget
- Update template to display hero section
- Add conditional title display when no hero is present
- Replace custom widgets with mainWidgets
- Update main area configuration
- Reorganize fields into logical groups
- Add hero group for title and header
- Add mainArea group for main content
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2025

Walkthrough

The changes introduce a new "Default Hero" widget module and restructure the page layout in the ApostropheCMS project. The main page type now separates the hero section from the main content by defining distinct header and main area fields, with the header area limited to the new hero widget. The page template is updated to render the hero area and conditionally display the page title. Minor formatting adjustments and blank lines are added in the main app configuration. No changes to core logic or control flow are present.

Changes

File(s) Change Summary
website/app.js Added blank lines for readability in createAposConfig; registered new default-hero-widget module.
website/modules/default-hero-widget/index.js,
website/modules/default-hero-widget/views/widget.html
Added new "Default Hero" widget module with fields for title, subtitle, and a background image area restricted to a single image widget; created corresponding widget template for rendering.
website/modules/default-page/index.js Refactored page type fields by splitting single main area into header (allowing only the Default Hero widget) and main (imported widget options); updated field groups to separate hero and main content areas.
website/modules/default-page/views/page.html Updated page template to render the new header area before the main area; conditionally render the page title only if the header area is empty.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PageTemplate
    participant DefaultHeroWidget

    User->>PageTemplate: Request page
    PageTemplate->>PageTemplate: Render 'header' area (Default Hero)
    alt If header is present
        PageTemplate-->>User: Render hero widget (title, subtitle, background image)
    else If header is absent
        PageTemplate-->>User: Render page title
    end
    PageTemplate->>PageTemplate: Render 'main' area (other widgets)
    PageTemplate-->>User: Render complete page
Loading
sequenceDiagram
    participant Editor
    participant PageAdminUI
    participant DefaultHeroWidget

    Editor->>PageAdminUI: Edit page
    PageAdminUI->>PageAdminUI: Show 'header' area (allows only Default Hero widget)
    PageAdminUI->>DefaultHeroWidget: Configure title, subtitle, background image
    PageAdminUI->>PageAdminUI: Show 'main' area (other widgets)
    Editor->>PageAdminUI: Save changes
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 402a93c and 9f3e154.

📒 Files selected for processing (1)
  • website/app.js (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/app.js
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: security-scan
  • GitHub Check: unit-tests
  • GitHub Check: lint

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2025

🔍 Vulnerabilities of apostrophe-cms:test

📦 Image Reference apostrophe-cms:test
digestsha256:97cbdd7e77c4e0d7a04b1c0ad3e6e8cdd13ff5d0371517f051599632e22288eb
vulnerabilitiescritical: 1 high: 2 medium: 0 low: 0
platformlinux/amd64
size643 MB
packages1447
📦 Base Image node:23-bullseye
also known as
  • 23.11-bullseye
  • 23.11.0-bullseye
  • bullseye
  • current-bullseye
digestsha256:128067b8c33d5ad2834513ed3351f29803280407037c2cc66957f0e5d1b3ddd1
vulnerabilitiescritical: 1 high: 0 medium: 6 low: 192 unspecified: 5
critical: 1 high: 0 medium: 0 low: 0 wget 1.21-1+deb11u1 (deb)

pkg:deb/debian/wget@1.21-1%2Bdeb11u1?os_distro=bullseye&os_name=debian&os_version=11

critical : CVE--2024--38428

Affected range<1.21-1+deb11u2
Fixed version1.21-1+deb11u2
EPSS Score0.216%
EPSS Percentile44th percentile
Description

url.c in GNU Wget through 1.24.5 mishandles semicolons in the userinfo subcomponent of a URI, and thus there may be insecure behavior in which data that was supposed to be in the userinfo subcomponent is misinterpreted to be part of the host subcomponent.


critical: 0 high: 1 medium: 0 low: 0 async 0.9.2 (npm)

pkg:npm/async@0.9.2

high 7.8: CVE--2021--43138 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<2.6.4
Fixed version2.6.4, 3.2.2
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score0.915%
EPSS Percentile75th percentile
Description

A vulnerability exists in Async through 3.2.1 (fixed in 3.2.2), which could let a malicious user obtain privileges via the mapValues() method.

critical: 0 high: 1 medium: 0 low: 0 async 1.5.2 (npm)

pkg:npm/async@1.5.2

high 7.8: CVE--2021--43138 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<2.6.4
Fixed version2.6.4, 3.2.2
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score0.915%
EPSS Percentile75th percentile
Description

A vulnerability exists in Async through 3.2.1 (fixed in 3.2.2), which could let a malicious user obtain privileges via the mapValues() method.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
website/modules/default-hero-widget/views/widget.html (1)

1-16: Clean and well-structured template implementation.

The template correctly implements the hero widget with proper conditionals and BEM-style class naming. The structure logically separates the background from the content.

Consider adding a few comments to improve maintainability:

{% set widget = data.widget %}

+{# Hero container with optional background #}
<div class="default-hero">
  {% if widget.backgroundImage %}
  <div class="default-hero__background">
    {% area widget, 'backgroundImage' %}
  </div>
  {% endif %}

+{# Hero content with title and optional subtitle #}
  <div class="default-hero__content">
    <h1 class="default-hero__title">{{ widget.title }}</h1>
    {% if widget.subtitle %}
    <p class="default-hero__subtitle">{{ widget.subtitle }}</p>
    {% endif %}
  </div>
</div>
website/modules/default-page/views/page.html (1)

5-7: Good conditional rendering of title based on hero presence.

The conditional logic to only show the page title when no header content exists is appropriate. However, the template formatting on line 7 is quite compressed, with multiple template tags on a single line without proper spacing.

Consider improving readability by formatting the template tags with proper spacing and line breaks:

-  {% if not data.page.header %}
-  <h1>{{ data.page.title }}</h1>
-  {% endif %} {% area data.page, 'header' %} {% area data.page, 'main' %}
+  {% if not data.page.header %}
+    <h1>{{ data.page.title }}</h1>
+  {% endif %}
+  
+  {% area data.page, 'header' %}
+  
+  {% area data.page, 'main' %}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80d790c and 76c5cd1.

📒 Files selected for processing (5)
  • website/app.js (2 hunks)
  • website/modules/default-hero-widget/index.js (1 hunks)
  • website/modules/default-hero-widget/views/widget.html (1 hunks)
  • website/modules/default-page/index.js (1 hunks)
  • website/modules/default-page/views/page.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: sonarqube
  • GitHub Check: security-scan
🔇 Additional comments (9)
website/modules/default-page/index.js (4)

1-2: Good modularization approach with external widgets configuration.

Importing widget configurations from an external file is a good practice that promotes code reusability and maintainability. This approach allows the same widget configuration to be used across different page types.


10-18: Good separation of hero section with appropriate constraints.

The creation of a dedicated header area with a maximum of 1 widget and limiting it to only the default-hero widget type is a good architectural decision. This ensures consistent page headers across the site and simplifies the content editing experience.


19-22: Improved structure using external widget configuration.

Replacing inline widget definitions with the imported mainWidgets configuration makes the code cleaner and more maintainable. This approach also ensures consistency across different areas of the application that use the same set of widgets.


25-32: Logical field grouping that improves editor experience.

The reorganization of fields into 'hero' and 'mainArea' groups creates a clear separation between the page header and main content in the CMS interface. This improves the content editing experience by providing a more intuitive organization of fields.

website/modules/default-hero-widget/index.js (1)

1-29: Well-structured implementation of the Default Hero widget.

The widget is properly defined with appropriate fields for a hero component (title, subtitle, and backgroundImage). Good job restricting the backgroundImage to a single image widget and marking the title as required. The code follows ApostropheCMS conventions and is well-formatted with consistent styling.

website/app.js (4)

15-21: Improved code style with trailing commas.

The formatting changes with trailing commas improve code consistency and will make future additions cleaner.


29-30: Consistent formatting applied to widget options.

Good application of trailing commas to the widget options objects for consistency.

Also applies to: 34-35


40-40: Successfully registered the new Default Hero widget.

The new widget module is properly added to the application configuration alongside other custom widgets.


82-83: Consistent trailing commas applied throughout.

Maintaining consistent code style with trailing commas at the end of the configuration.

@VitalyyP VitalyyP self-assigned this Apr 22, 2025
Copy link
Copy Markdown
Contributor

@yuramax yuramax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown
Contributor

@Anton-88 Anton-88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@IhorMasechko IhorMasechko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@VitalyyP VitalyyP requested a review from killev April 23, 2025 06:18
Copy link
Copy Markdown
Collaborator

@killev killev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approved

@sonarqubecloud
Copy link
Copy Markdown

@VitalyyP VitalyyP merged commit f0261cc into main Apr 23, 2025
10 checks passed
@VitalyyP VitalyyP deleted the 431-feature/update-default-page-template branch April 23, 2025 09:46
@coderabbitai coderabbitai Bot mentioned this pull request Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants